package cn.edu.zafu.bigdata.psy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

public class TCPClient {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("192.168.16.72", 8888);

            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);

            BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
            String userMessage;
            while ((userMessage = consoleReader.readLine())!= null) {
                out.println(userMessage);
                System.out.println("服务器回复：" + in.readLine());
            }

            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
